package cn.getech.data.development.mapper;

import cn.getech.data.development.entity.TableRelation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.stringtemplate.v4.ST;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * 表关系 Mapper 接口
 * </p>
 *
 * @author zenith
 * @since 2019-07-08
 */
@Mapper
public interface TableRelationMapper extends BaseMapper<TableRelation> {

    void insertIfNotExists(TableRelation TableRelation);

    void deleteSubjectRelation( @Param("id") Integer id, @Param("subjectId") Integer subjectId,
                                @Param("tableType")Integer tableType);

    void addSubjectRelation(@Param("id") Integer id, @Param("subjectId") Integer subjectId,
                            @Param("userId") Long userId, @Param("tableType")Integer tableType);

    void deleteCategoryRelation(@Param("id") Integer id, @Param("categoryId") Integer categoryId,
                                @Param("tableType")Integer tableType);

    void addCategoryRelation(@Param("id") Integer id, @Param("categoryId") Integer categoryId,
                             @Param("userId") Long userId, @Param("tableType")Integer tableType);

    /**
     *
     * @param id 表id
     * @param tableType  1 离线表   2 实时表
     * @return
     */
    Set<Integer> selectCategoryIds(@Param("id") Integer id ,@Param("tableType")Integer tableType);

    /**
     *
     * @param id 表id
     * @param tableType  0 离线表   1 实时表
     * @return
     */
    Set<Integer> selectSubjectIds(@Param("id")Integer id,@Param("tableType")Integer tableType);

    @MapKey("userId")
    List<Map<String, Object>> getUserList(@Param("type") Integer type,@Param("procId") Integer procId);

    List<String> selectCategoryIdsList(@Param("id") Integer id);
}
